package com.utils;

import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.view.Gravity;
import android.widget.Toast;

import com.loopj.android.http.AsyncHttpResponseHandler;
import com.takeshequ.LoginActivity;

public class BasicAsyncHttpResponseHandler extends AsyncHttpResponseHandler {
	private ProgressDialog dialog;
	private Context context;
	private String title;
	private String content;

	public BasicAsyncHttpResponseHandler(Context context, String title,
			String content) {
		this.context = context;
		this.title = title;
		this.content = content;
	}

	@Override
	public void onStart() {
		dialog = ProgressDialog.show(context, title, content, true);
	}

	@Override
	public void onSuccess(String response) {
		onSuccessCustomer(response);
	};

	public void onSuccessCustomer(String response) {

	}

	@Override
	public void onFailure(Throwable e, String response) {
		Toast toast = Toast.makeText(context, "无法连接,请稍后再试....", 5000);
		toast.setGravity(Gravity.CENTER, 0, 0);
		toast.show();
		context.startActivity(new Intent(context,LoginActivity.class));
		
	}

	@Override
	public void onFinish() {
		dialog.dismiss();
	}
}
